const Koa = require('koa');
const chalk = require('chalk');
const app = new Koa();
const registerRouter  = require('./router')
const parameter = require('koa-parameter');
const koaBody=require("koa-body");
const koaStatic = require('koa-static');
const path = require('path')

app.use(koaStatic(path.join(__dirname,'public')));
app.use(koaBody({
  multipart: true,
  strict:false,
  formidable: {
    uploadDir: path.join(__dirname, '/public/images'),
    keepExtensions: true
  }
}));

app.use(parameter(app));
app.use(registerRouter());
app.listen(3000);
console.log('App is running at ' + chalk.yellow(`http://localhost:3000`));